//
//  ViewController.swift
//  RouterDemo
//
//  Created by lizhi on 2022/2/24.
//

import UIKit
import URLNavigator

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "首页"
        // Do any additional setup after loading the view.
        
        let button = UIButton(frame: CGRect(x: 100, y: 200, width: 150, height: 60))
        button.setTitle("点击", for: .normal)
        button.backgroundColor = .blue
        self.view.addSubview(button)
        button.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
        
        let button2 = UIButton(frame: CGRect(x: 100, y: 400, width: 150, height: 60))
        button2.setTitle("点击-播放页", for: .normal)
        button2.backgroundColor = .blue
        self.view.addSubview(button2)
        button2.addTarget(self, action: #selector(buttonClick2), for: .touchUpInside)
        
    }
   @objc func buttonClick()  {
        print("-- buttonClick")
//       RouterManager.shared.navigator.push("myapp://user/123")

       let userInfo = RouterUserInfo(userID: 11, name: "用户名称")
       let key = RouterKey.User_Key(param: userInfo)
       let vc = RouterMap.controller(for: key)
       if vc != nil {
           self.navigationController?.pushViewController(vc!, animated: true)
       }
    }
    
    @objc func buttonClick2()  {
         print("-- buttonClick 2")
 //       RouterManager.shared.navigator.push("myapp://user/123")
        let vc = RouterMap.shared.navigator.viewController(for: RouterMap.play_key)
        if vc != nil {
            self.navigationController?.pushViewController(vc!, animated: true)
        }
        
        
     }


}

